/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kungkhies.jms.kungkhie.upload.validate.error;


import com.kungkhies.domain.kspace.KSpaceMessage;
import com.kungkhies.domain.kspace.enums.KSpaceMessageType;
import com.kungkhies.persistence.kspace.KSpaceMessageDao;
import com.kungkhies.persistence.kungkher.KungkherDao;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;

/**
 *
 * @author clayton
 */
public class KungkhieUploadValidateErrorHandler
{
    private KSpaceMessageDao kSpaceMessageDao;
    private KungkherDao kungkherDao;
    
    @Autowired
    public KungkhieUploadValidateErrorHandler(KSpaceMessageDao kSpaceMessageDao, KungkherDao kungkherDao)
    {
        this.kSpaceMessageDao = kSpaceMessageDao;  
        this.kungkherDao = kungkherDao;
    }
    
    public void processKungkhieError(HashMap message)
    {
        String errorMessage = (String) message.get("kungkhieValidateError");
        String kungkherName = (String) message.get("kungkherName");
        
        KSpaceMessageType messageType = KSpaceMessageType.kungkhie_validate_error;
        
        long kungkherId = kungkherDao.getKungkherByUsername(kungkherName).getId();
        
        KSpaceMessage kSpaceMessage = new KSpaceMessage();
        
        kSpaceMessage.setKungkherId(kungkherId);
        kSpaceMessage.setMessageType(messageType.getMessageType());
        kSpaceMessage.setIsDisplayed(true);
        kSpaceMessage.setMessageString(errorMessage);
    }   
}
